Density Graph Example

FILE: Density.cln

Introduction

This is an example of the use of Density Input and Density Output graphs. It also illustrates the Cog object.

Scenario

Volmo are a major car manufacturer, who manufacture Camper Kits to convert their cars into campers (cars with tents or sleeping sections).

You manufacture showers (under the trade name Shifting Showers) for these campers.

You want to know where you should target your sales effort.

Analysis

Your only potential customers are people who a) Own and Volmo Car and b) Have bought the Camper conversion kit.

If we have the information on Volmo sales and information on Camper kit sales, then we can calculate where our missed sales opportunities are.

You may wonder why we need the sales of Volmo cars, since nobody would buy a conversion kit if they didn't have the car. The reason we are going to include these figures is, because not everyone who buys a conversion kit buys it in the same place as they bought the car, hence including them should give us a better approximation.

If we take whichever is the lowest, the number of Campers sold in a region, or the number of Volmo cars sold in a region, and subtract the number of sales we have made in that region, that will give us a rough estimate of the missed sales.

The Sheet

The resulting sheet we use to tackle the problem looks like this.

It consists of 3 Density Graph Input objects and 1 Density Graph Output object. All the calculation is done by a single Cog Object. Click on each for an explanation of what they do.


The Sales We Have Made

This is the density input used to enter our sales for each region. To recreate this object:

Drop a density input object onto the sheet

Select Use Mode

Load the file Density.Clp (the map) into the Clipboard using the Windows Clipboard Viewer.

Paste this map into the background of the object.

Set the Density Paint Mode to Move and Resize Components.

Size and position the background, index box, and title.

Size the grid to cover the main section of the map

Select Edit Mode

Set the number of rows and columns in the grid using the  Row Column Size dialogue. (20 rows 10 columns).

Set the Map Style dialogue so that the input object enters values between the two fixed limits 0 and 100. Since we have not sold more than 100 units in any region this is a sensible display type.

Set the Density Paint Mode to Paint the Data.


Sales of Camper Conversion Kits

This is a density input graph used to enter the numbers of Camper conversion kits sold. To recreate it, take the following steps.

Drop a density input object onto the sheet

Select Use Mode

Load the file Density.Clp (the map) into the Clipboard using the Windows Clipboard Viewer.

Paste this map into the background of the object.

Set the Density Paint Mode to Move and Resize Components.

Size and position the background, index box, and title.

Size the grid to cover the main section of the map

Select Edit Mode

Set the number of rows and columns in the grid using the  Row Column Size dialogue. (20 rows 10 columns).

Set the Map Style dialogue such that the input object enters values between the two fixed limits 0 and 1000. Since there hasn't been more than 1000 units of the conversion kit sold in any one area, this is a sensible limit.

Set the Density Paint Mode to Paint the Data.


Sales of Volmo Cars

This is a density input graph used to enter the numbers of Volmo Cars sold.

Drop a density input object onto the sheet

Select Use Mode

Load the file Density.Clp (the map) into the Clipboard using the Windows Clipboard Viewer.

Paste this map into the background of the object.

Set the Density Paint Mode to Move and Resize Components.

Size and position the background, index box, and title.

Size the grid to cover the main section of the map

Select Edit Mode

Set the number of rows and columns in the grid using the  Row Column Size dialogue. (20 rows 10 columns).

Set the Map Style dialogue such that the input object enters values between the two fixed limits 0 and 3000. There haven't been more than 3000 units sold in any one area, so it is sensible to set these two limits.

Set the Density Paint Mode to Paint the Data.


This is the Output Density Graph used to display the finished results. To recreate this object:

Drop a density output graph object onto the sheet

Select Use Mode

Load the file Density.Clp (the map) into the Clipboard using the Windows Clipboard Viewer.

Paste this map into the background of the object.

Size and position the background, index box, and title.

Size the grid to cover the main section of the map

Select Edit Mode

Set the number of rows and columns in the grid using the  Row Column Size dialogue. (20 rows 10 columns).


All of the calculating is done with a single Cog object. To create the Cog object:

Drop a Cog Object onto the sheet

Set the number of inputs to 3 using the Number of Inputs dialogue.

Link the 'Sales of Showers' density input into Inlet A

Link the 'Sales of Camper Kits' input into Inlet B

Link the 'Sales of Volmo Cars' input into Inlet C.

Link the output to the Output Density Graph.

Set the equation

A single equation affects all of the output array, it is min{make{B[dx][dy],3},make{C[dx][dy],3}} - A[dx][dy]

It's much easier to break this equation into parts.

A[dx][dy], B[dx][dy] and C[dx][dy] are used by the Cog object to retrieve element dx/dy of each of the input arrays. Corresponding elements of each of the three inputs are used.

make{...,3} converts the object in each cell to type 3 (a double precision number).

min{} returns the minimum of, the number of conversion kits sold and, the number of Volmo cars sold.

You may wonder why we bother with the make{...,3} step since the Input array only produces numbers anyway. The reason is that empty cells on the Input Density Graph are NULL, not Zero. The minimum function ignores Nulls, so min{NULL,1000} ireturns 1000.

We need to ensure that NULLs become Zeros - Converting the object we obtain into a double precision number does this.